  var directionDisplay;
      var directionsService = new google.maps.DirectionsService();
var AllInfoPage = Objs("view.components.AllInfoPage",
	UiComponent,
{   
   	modelComp:null,
	phoneComp:null,
	registercomment:null,
	registerpnote:null,
	
	singlemap:null,
        directionmap:null,
	initialize: function()
	{ 
	
		AllInfoPage.$super.initialize.call( this );
		this.initializeChildren();
		this.bindListeners();
		this.intializeMap();
		
	},
	
	intializeMap: function()
	{
		
             if(document.getElementById("direction-map")) 
             {
               directionsDisplay = new google.maps.DirectionsRenderer();
                var singleInfoMap = document.getElementById("direction-map");
                singleInfoMap.style.width = '100%';
		singleInfoMap.style.height = '300px';
		center = new google.maps.LatLng(37.423021 , -122.083739);
		myOptions = {
				zoom: 6,
				center:center,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			}
              directionmap = new google.maps.Map(document.getElementById('direction-map'), myOptions);
              directionsDisplay.setMap(directionmap);
              directionsDisplay.setPanel(document.getElementById('direction-route'));
            }  
            
	},
	
    initializeChildren: function()
    {
		this.modelComp = jQuery("#make");
		this.phoneComp = jQuery("#phone");
		
		this.registercomment = jQuery("#commentadd");
		this.registerpnote = jQuery("#pnoteadd");
		this.removeby = jQuery('#remove_by');
    },
	
	bindListeners: function()
	{
		var namespace = ".AllInfoPage";
	
   		this.modelComp.on( "change"+namespace, jQuery.proxy( this, "modelComp_clickHandler" ) );
		this.phoneComp.on( "click"+namespace, jQuery.proxy( this, "phoneComp_clickHandler" ) );
		//this.removeby.on("click"+namespace, jQuery.proxy( this, "removeby_clickHandler"));
		this.registercomment.on( "click"+namespace, jQuery.proxy( this, "registerComment_clickHandler" ) );
		this.registerpnote.on( "click"+namespace, jQuery.proxy( this, "registerpnote_clickHandler" ) );
		
	},
	
	registerComment_clickHandler:function()
	{
		this.dispatchEvent( AllInfoPage.ADD_MESSAGE );	

	},
	registerpnote_clickHandler:function()
	{
	
		this.dispatchEvent( AllInfoPage.ADD_PNOTE );	

	},
	
	/*removeby_clickHandler: function()
	{
		//alert("sfdfdf");
		//this.removeby.val("sadasd");
		//this.removeby.datepicker();
		//$( "#remove_by" ).datepicker();
	},*/
	modelComp_clickHandler: function()
	{
	
		var makeField = document.getElementById('make').value;
		$(xmld).find('make').each(function(){
			$(this).find('label').each(function(){
				if($(this).text()==makeField)
				{
					var datafield=$(this).attr('dataField');
					$('select#model').empty();
					var modelxml = '<option value="0">--Choose One--</option>';
					$(xmld).find(datafield).each(function(){
						$(this).find('item').each(function(){
							$(this).find('label').each(function(){
								var models = $(this).text();
								modelxml += '<option>'+models+'</option>';
							});
						});
					});
					
					$('select#model').append(modelxml);
					$("select#model").trigger("change");
				}
			});
		
		});
	},
	phoneComp_clickHandler: function()
	{
		
	}


});
AllInfoPage.ADD_MESSAGE="addmess";
AllInfoPage.ADD_PNOTE="addpnote";
